﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using mitasoft.Component.Services.Interfaces;

namespace mitasoft.Web.Controllers
{
    public class BlogController : Controller
    {
        private const int RECENT_POSTS_COUNT = 3;
        private IBlogService _blogService;

        public BlogController(IBlogService blogService)
        {
            _blogService = blogService;
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetTags()
        {
            var data = _blogService.RetriveCategoryTags();
            return View(data);
        }

        public ActionResult GetRecentPostsPart(int? page)
        {
            int skip = page.HasValue ? (page.Value - 1) * RECENT_POSTS_COUNT : 0;

            var posts = _blogService.GetRecentPostPaginated(skip, RECENT_POSTS_COUNT);

            return View(posts);
        }
    }
}
